<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="/templates/ui.xhtml">

<ui:define name="head">
    <style type="text/css">
        .input-col-m {
            width: 60px;
        }

        .input-col-l {
            width: 80px;
        }

        .input-col-xxl {
            width: 1%;
            text-align: right;
        }

        .col-95 {
            text-align: right;
        }

        .col-5 {
            text-align: left;
        }
    </style>
    <script type="text/javascript" src="#{request.contextPath}/UI/support/pub.js" charset="GBK"/>
    <script type="text/javascript" language="javascript">
        document.onkeydown = function TabReplace() {
            if (event.keyCode == 13) {
                if (event.srcElement.tagName != 'BUTTON')
                    event.keyCode = 9;
                else
                    event.srcElement.click();
            }
        }
        function qryBanks() {
            var sfeature = "dialogwidth:800px; dialogheight:600px;center:yes;help:yes;resizable:yes;scroll:yes;status:yes";
            var arg = new Object();
            var rtn = dialog("../common/bankList.xhtml", arg, sfeature);
            if (rtn != null) {
                document.getElementById("form:toBankCode").value = rtn.bankCode;
                document.getElementById("form:toBankName").value = rtn.bankName;
            }
        }

        function selectTransType() {
            var transType = document.getElementById("form:transType").value;
            if (transType === '10') {
                document.getElementById("form:toBankCode").disabled = true;
                document.getElementById("form:toBankName").disabled = true;
                document.getElementById("form:docNo").disabled = true;
                document.getElementById("form:voucherType").disabled = true;
            }
            if (transType === '20') {
                document.getElementById("form:toBankCode").disabled = false;
                document.getElementById("form:toBankName").disabled = false;
                document.getElementById("form:docNo").disabled = false;
                document.getElementById("form:voucherType").disabled = false;
            }

        }
    </script>

</ui:define>

<ui:define name="content">
    <div style="margin:5px;">
        <p:growl id="msgs" showDetail="false"/>
        <h:form id="form">
            <p:focus for="toAccountCode"/>
            <p:panel id="input" header="实际用款表单">
                <h:panelGrid columns="1" cellspacing="2" style="width: 100%">
                    <h:panelGrid columns="1" cellspacing="2" style="width: 100%">

                        <p:fieldset legend="用款计划">
                            <h:panelGrid columns="1">
                                <h:panelGrid columns="4" cellpadding="2" columnClasses="col-95,col-5,col-95,col-5"
                                             style="width: 100%">
                                    <h:outputLabel value="计划编号:" for="planNo" size="30" style="margin-left: 44px;"/>
                                    <p:inputText id="planNo" value="#{cbusPayoutAction.rsPayout.businessNo}"
                                                 readonly="true" disabled="true" style="width:160px;"/>
                                    <h:outputLabel value="计划金额:" for="planAmt" size="30"
                                                   style="margin-left: 44px;"/>
                                    <p:inputText id="planAmt" value="#{cbusPayoutAction.planCtrl.plAmount}"
                                                 readonly="true" disabled="true" style="width:260px;">
                                        <f:convertNumber pattern="#,###,###,###,##0.00"/>
                                    </p:inputText>
                                    <h:outputLabel value="可用金额:" for="avAmt" size="30" style="margin-left: 44px;"/>
                                    <p:inputText id="avAmt" value="#{cbusPayoutAction.planCtrl.avAmount}"
                                                 readonly="true" disabled="true" style="width:160px;">
                                        <f:convertNumber pattern="#,###,###,###,##0.00"/>
                                    </p:inputText>
                                    <h:outputLabel/><h:outputLabel/>
                                </h:panelGrid>
                            </h:panelGrid>
                        </p:fieldset>

                        <p:fieldset legend="收款方信息">
                            <h:panelGrid columns="1">
                                <h:panelGrid columns="4" cellpadding="2" columnClasses="col-95,col-5,col-95,col-5"
                                             style="width: 100%">
                                    <h:outputLabel value="*收款方账号:" for="toAccountCode" size="40"
                                                   style="margin-left: 25px;"/>
                                    <p:inputText id="toAccountCode" value="#{cbusPayoutAction.rsPayout.recAccount}"
                                                 readonly="false" style="width:160px;" required="true"
                                                 requiredMessage="必须输入收款方账号！"/>

                                    <h:outputLabel value="*收款方户名:" for="toAccountName" size="40"
                                                   style="margin-left: 25px;"/>
                                    <p:inputText id="toAccountName"
                                                 value="#{cbusPayoutAction.rsPayout.recCompanyName}"
                                                 readonly="false" required="true" requiredMessage="必须输入收款方户名！"
                                                 style="width:260px;"/>

                                    <h:outputLabel value="转账方式:" for="transType"/>
                                    <h:selectOneMenu id="transType" style="width:166px;" onchange="selectTransType()"
                                                     value="#{cbusPayoutAction.rsPayout.transType}">
                                        <f:selectItems value="#{cbusPayoutAction.payTypes}"/>
                                    </h:selectOneMenu>

                                    <h:outputLabel/>
                                    <h:outputLabel/>

                                    <h:outputLabel value="收款行:" for="toBankCode" size="40"
                                                   style="margin-left: 25px;"/>
                                    <p:inputText id="toBankCode" style="width:160px;"
                                                 value="#{cbusPayoutAction.rsPayout.recBankCode}"
                                                 onclick="qryBanks()"/>

                                    <h:outputLabel value="收款行全称:" for="toBankName" size="40"
                                                   style="margin-left: 25px;"/>
                                    <p:inputText id="toBankName" value="#{cbusPayoutAction.rsPayout.recBankName}"
                                                 readonly="false"
                                                 style="width:260px;"/>
                                </h:panelGrid>
                            </h:panelGrid>
                        </p:fieldset>
                        <p:fieldset legend="付款方信息">
                            <h:panelGrid columns="1">
                                <h:panelGrid columns="4" cellspacing="2" style="width: 100%"
                                             columnClasses="col-95,col-5,col-95,col-5">

                                    <h:outputLabel value="*付款房产商:" for="companyName" size="40"
                                                   style="margin-left: 25px;"/>
                                    <h:inputText autocomplete="off" id="companyName" style="width:160px;"
                                                 readonly="false" required="true" requiredMessage="必须输入付款开发商！"
                                                 value="#{cbusPayoutAction.rsPayout.payCompanyName}">
                                    </h:inputText>

                                    <h:outputLabel value="付款账号:" for="accountCode" size="40"
                                                   style="margin-left: 25px;"/>
                                    <p:inputText autocomplete="off" id="accountCode" style="width:250px;"
                                                 readonly="true" disabled="true"
                                                 value="#{cbusPayoutAction.rsPayout.payAccount}">
                                    </p:inputText>

                                    <h:outputLabel value="凭证号:" for="docNo" size="40" style="margin-left: 25px;"/>
                                    <p:inputText id="docNo" value="#{cbusPayoutAction.rsPayout.docNo}"
                                                 style="width:160px;"/>


                                    <h:outputLabel value="*申请金额:" for="applyAmt" size="40"
                                                   style="margin-left: 25px;"/>
                                    <p:inputText autocomplete="off" id="applyAmt" style="width:250px;"
                                                 required="true"
                                                 requiredMessage="必须输入申请金额！"
                                                 value="#{cbusPayoutAction.rsPayout.plAmount}">
                                    </p:inputText>

                                    <h:outputLabel value="凭证种类:" for="voucherType" size="40"
                                                   style="margin-left: 25px;"/>
                                    <h:selectOneMenu id="voucherType" style="width:166px;"
                                                     value="#{cbusPayoutAction.rsPayout.voucherType}">
                                        <f:selectItems value="#{cbusPayoutAction.voucherTypes}"/>
                                    </h:selectOneMenu>

                                    <h:outputLabel/><h:outputLabel/>
                                </h:panelGrid>
                                <h:panelGrid columns="2" cellspacing="2" style="width: 100%"
                                             columnClasses="col-95,col-5,col-95,col-5">
                                    <h:outputLabel value="*付款用途:" for="applyReason"
                                                   style="text-align: right;margin-left: 37px;" size="30"/>
                                    <p:inputText autocomplete="off" id="applyReason" style="width:540px;"
                                                 value="#{cbusPayoutAction.rsPayout.purpose}" required="true"
                                                 requiredMessage="必须输入付款用途！">
                                    </p:inputText>
                                </h:panelGrid>
                            </h:panelGrid>
                        </p:fieldset>
                    </h:panelGrid>
                    <h:panelGrid style="width: 20%" columns="2">
                        <p:commandButton id="saveBtn" ajax="true" value="提交"
                                         action="#{cbusPayoutAction.onSave}"
                                         style="margin-left:240px;width:90px"
                                         update="input,pdt,msgs">
                        </p:commandButton>
                        <p:commandButton ajax="true" id="clsBtn" value="关闭" onclick="window.close();"
                                         style="width:90px;margin-left:15px" update="input,msgs"/>
                    </h:panelGrid>
                </h:panelGrid>
            </p:panel>
            <p:ajaxStatus style="width:16px;height:16px;">
                <f:facet name="start">
                    <h:graphicImage value="/images/ajaxloading.gif"/>
                </f:facet>
                <f:facet name="complete">
                    <h:outputText value=""/>
                </f:facet>
            </p:ajaxStatus>
        </h:form>
    </div>
</ui:define>

</ui:composition>